package ebj.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Utils {
	public static Properties getProperties() {
		Properties properties = new Properties();
		InputStream inputStream = Utils.class.getResourceAsStream("/config.properties");
		try {
			properties.load(inputStream);
			inputStream.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return properties;
	}
	
	public static Properties getProperties(String fileName) {
		Properties properties = new Properties();
		InputStream inputStream = Utils.class.getResourceAsStream("/" + fileName + ".properties");
		try {
			properties.load(inputStream);
			inputStream.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return properties;
	}
	
	public static String getProperty(String propertyName) {
		Properties properties = new Properties();
		InputStream inputStream = Utils.class.getResourceAsStream("/config.properties");
		try {
			properties.load(inputStream);
			inputStream.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return properties.getProperty(propertyName);
	}
	
	public static String getProperty(String fileName, String propertyName) {
		Properties properties = new Properties();
		InputStream inputStream = Utils.class.getResourceAsStream("/" + fileName + ".properties");
		try {
			properties.load(inputStream);
			inputStream.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return properties.getProperty(propertyName);
	}
}
